# -*- coding: utf-8 -*-

#AU Modülleri

import buildarc as arc
import os
import sys
import hatalar
import shutil

def build():
  if os.path.isdir("/tmp/au/build"):
    pass
  else:
    os.makedirs("/tmp/au/build")
  print "Derleme başlatılıyor"
  try:
    
    import pakinfo
  except:
    hatalar.pakinfoerror()
  if pakinfo.buildtype == "private":
    try:
      import pakbuild
    except:
      hatalar.pakbuilderror()
  else:
    pass
  print "Paket indiriliyor"
  arc.dizin()
  arc.indir(pakinfo.bfile)
  lista = os.listdir(os.curdir)
  dosya = lista[0]
  if pakinfo.btype == "tarbz2":
    arc.tarbz2(dosya)
  if pakinfo.btype == "targz":
    arc.targz(dosya)
  print "Paket derleniyor"
  os.chdir(os.pardir)
  if pakinfo.buildtype == "make":
    arc.make()
  name = ("%s_%s-%s.tar.pak" %(pakinfo.pakname, pakinfo.version, pakinfo.build))
  os.system("tar cf %s build/" %(name))
  shutil.copy(name, "/au/")
  print "Paket /au dizinine kopyalandı"


  